package com.zzh.controller;

import com.alibaba.fastjson.JSONObject;
import com.zzh.controller.utils.R;
import com.zzh.ov.PageAndKey;
import com.zzh.service.impl.VideoInfoServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/*
 * @Auther : wenrouyue
 * @Date : 2022/3/11-0:27
 */
@RestController
@RequestMapping("/videos")
public class VideoInfoController {
    @Autowired
    private VideoInfoServiceImpl videoInfoService;
    @GetMapping("/getinfo/{page}/{size}")
    public R getInfo(@PathVariable int page,@PathVariable int size){
        return videoInfoService.getPage(page,size);
    }
//    @PostMapping("/getvideo")
//    public R getInfoByWord(@RequestBody JSONObject pageParam){
//        int page = 1;
//        int size = 5;
//        String word = (String) pageParam.get("keyWord");
//        if (pageParam.get("page") == null || pageParam.get("size") == null){
//            return videoInfoService.getPageByKeyWord(page,size,word);
//        }else {
//            int pageI = pageParam.getInteger("page");
//            int sizeI = pageParam.getInteger("size");
//            return videoInfoService.getPageByKeyWord(pageI,sizeI,word);
//        }
//    }
    @PostMapping("getVideoInfo")
    public R getVideoInfo(@RequestBody PageAndKey pageAndKey){
        return videoInfoService.getPageByKey(pageAndKey);
    }

    @GetMapping("getVideo/{id}")
    public R getVideoInfo(@PathVariable Integer id){
        return videoInfoService.getVideoById(id);
    }


}
